﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Lcygcc.Infrastructure.Repository
{
    /// <summary>
    /// 仓储接口，定义公共的泛型GRUD
    /// </summary>
    /// <typeparam name="TEntity">泛型聚合根，因为在DDD里面仓储只能对聚合根做操作</typeparam>
    public interface IRepository<T> where T : class, new()
    {
        #region 公共方法

        SqlSugarClient db
        {
            get;
        }
        ISugarQueryable<T> Table
        {
            get;
        }
        IQueryable<T> TableNoTracking
        {
            get;
        }
        T GetById(object id);
        T Insert(T entity);
        void Insert(IEnumerable<T> entities);
        void Update(T entity);
        void Update(IEnumerable<T> entities);
        void Delete(T entity);
        void Delete(IEnumerable<T> entities);
        IList<T> SqlQuery(string sql, params object[] parameters);
        int ExecuteSqlCommand(string sql, params object[] parameters);
        string GetDbTime();
        string GetConnectionString();

        #endregion
    }
}
